const path = require("path");
const fs = require("fs");
const log_path = path.resolve(__dirname, "../log/error.log.txt");
async function ErrorHandler(ctx, next) {
  try {
    await next();
  } catch (e) {
    console.log(e);
    if (e.code) {
      ctx.body = e;
    } else {
      ctx.body = {
        code: 40086,
        msg: "服务器内部错误"
      };
    }
  }
}

module.exports = ErrorHandler;
